home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-06 | 7.0 KB | 291 lines | [TEXT/KAHL] |
- // ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- // • Program: FrameAnim
- // • File: FrameAnim.h
- // •
- // • Copyright © 1993 by Scott B. Steinman, O.D., Ph.D. All Rights Reserved.
- // ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
-
- #ifndef __FrameAnim__
- #define __FrameAnim__
-
- #include <stdio.h>
- #include <stddef.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include <math.h>
- #include <setjmp.h>
- #include <assert.h>
- #include <ansi_private.h>
-
- #include <GestaltEqu.h>
- #include <QDOffscreen.h>
- #include <Palettes.h>
- #include <Fonts.h>
- #include <OSUtils.h>
- #include <Retrace.h>
- #include <Slots.h>
-
- // • ------------------ General Definitions -------------------------------
-
- #define Null 0L
- #define NullHandle 0L
- #define NullPointer 0L
- #define NoFlags 0
- #define NilString "\p"
-
- // • ------------------ ToolBox Traps -------------------------------------
-
- pascal long GetVBLRec( void ) = 0x2E88; // • Push A0 onto stack
-
- // • ------------------ ToolBox Definitions -------------------------------
-
- #define kMinSleep 0L
- #define kNilMouseRegion 0L
-
- enum {
- kRemoveAllEvents = 0,
- kMoveToFront = -1
- };
-
- // • ------------------ Menu Resource IDs ---------------------------------
-
- enum {
- kMBarID = 400,
- kAppleID = 401,
- kFileID = 402,
- kAnimID = 403
- };
-
- // • ------------------ Menu Item Number Definitions ----------------------
-
- enum {
- kAboutAnimItem = 1 // • Apple Menu Items
- };
-
- enum {
- kOpenFilmItem = 1, // • File Menu Items
- kSaveFilmItem = 2,
- kQuitItem = 4
- };
-
- enum {
- kPlayItem = 1, // • Animation Menu Items
- kFrameSzItem = 3,
- kGrayItem = 4,
- kFilmItem = 6
- };
-
- // • ------------------ Resource ID for PICS Animation File ---------------
-
- enum {
- kFirstPictID = 1000,
- kPICSInfoID = 1000,
- kColTableID = 1000
- };
-
- // • ------------------ Alert Resource IDs --------------------------------
-
- enum {
- kAboutAlertID = 600,
- kErrorAlertID = 601,
- kMachineAlertID = 602,
- kFPUAlertID = 603,
- kQD32BitAlertID = 604,
- kSystem7AlertID = 605
- };
-
- // • ------------------ Dialog Box Resource IDs ---------------------------
-
- enum {
- kFilmDlgID = 800,
- kFrameSzDlgID = 801,
- kMonitorDlgID = 802,
- kGrayDlgID = 803
- };
-
- enum {
- kMonitorDlgGoAhead = 1,
- kMonitorDlgMainMon = 2,
- kMonitorDlgSecMon = 3,
- kMonitorDlgCancel = 4
- };
-
- enum {
- kFilmDlgGoAhead = 1,
- kFilmDlgNumFrames = 2,
- kFilmDlgFrameDelay = 3,
- kFilmDlgSizeDiff = 4,
- kFilmDlgCancel = 5
- };
-
- enum {
- kFrameSzDlgGoAhead = 1,
- kFrameSzDlgDiam = 2,
- kFrameSzDlgCancel = 3
- };
-
- enum {
- kGrayDlgGoAhead = 1,
- kGrayDlgBkgndGray = 2,
- kGrayDlgTargetGray = 3,
- kGrayDlgCancel = 4
- };
-
- // • ------------------ Error-message String Resource IDs -----------------
-
- enum {
- kErrorMessageStrsID = 1000, // • Error-Message STR# Resource ID
- kNoWindMsg = 1, // • Error-Message String Offsets
- kNoMBarMsg = 2,
- kNoMenuRsrcMsg = 3,
- kNoMemoryMsg = 4,
- kNoGWorldMsg = 5,
- kGWorldUpdateMsg = 6,
- kNoDepthMsg = 7
- };
-
- // • ------------------ Color-specific Definitions ------------------------
-
- enum {
- kNumColors = 16,
- kDepth = 4 // • Number of bits per pixel for 16 colors
- };
-
- enum {
- kPalWhite = 0, // • Palette index for white
- kPalBlack = 15, // • Palette index for black
- kPalBkgnd = 2, // • Palette index for background gray
- kPalTarget = 3 // • Palette index for target gray
- };
-
- // • ------------------ Color Lookup Table Resource ID --------------------
-
- enum {
- kGrayCTableID = (kDepth+32) // • Gray ramp resource ID = depth + 32
- };
-
- // • ------------------ Monitor for Display of Stimulus -------------------
-
- enum {
- kMain = 0,
- kSecondary = 1
- };
-
- // • ------------------ Animation Definitions -----------------------------
-
- #define kFatalErrorMsg "\pFatal Error!!" // • Error Alert Dlg message
- #define kRefreshRate 66.7 // • Apple RGB monitor refresh rate (Hz)
-
- enum {
- kMaxFrames = 60, // • Max. number of frames in sequence
- kMaxSizeDiff = 20 // • Max. target size change per frame
- };
-
- enum {
- kHorizontal = 0, // • Horizontal direction on screen
- kVertical = 1 // • Vertical direction on screen
- };
-
- // • ------------------ PICS Animation Resource Data Definition -----------
-
- typedef struct {
- short bwColor; // • B/W (0) or color (1) ?
- short depth; // • Pixel depth
- short speed; // • Positive = frames/sec, negative = sec/frame
- short version; // • Current version is 0
- ResType creator; // • Original creator signature
- long largest; // • Optional field - largest picture size
- } PICSInfoRec, *PICSInfoPtr, **PICSInfoHandle;
-
- // • ------------------ Program Flags Data Definition ---------------------
-
- typedef struct Flags {
- Boolean cancel; // • True = Dialog box has been cancelled
- Boolean done; // • True = End of program
- } Flags;
-
- // • ------------------ Animation Settings Data Definition ----------------
-
- typedef struct Settings {
- long targetGray; // • Gray-scale values
- long bkgndGray;
- long frameSize; // • Frame width (and height) in pixels
- long numFrames; // • Number of animation frames
- long frameDelay; // • Speed of motion display
- long sizeDiff; // • Difference in target size per frame
- long currDepth; // • Monitor depth at onset of program
- short numMonitors; // • Number of monitors in this system
- short displayMonitor; // • Which monitor to show stimulus on
- } Settings;
-
- // • ------------------ Extended VBLTask Record Data Definition -----------
-
- typedef struct XVBLTask {
- VBLTask vbl;
- long a5;
- long frames; // • Number of frames
- long frameDelay; // • VBlanks between frames
- long frameIndex; // • Current frame number
- short showFrame; // • Display frame now?
- } XVBLTask, *XVBLTaskPtr;
-
- // • ------------------ Function Prototypes -------------------------------
-
- // • A N I M A T I O N . C
-
- void DisposeFrames( void );
- void DoFilm( void );
- void FindOrigin( void );
- void PlayFilm( void );
- void PrepareFilm( void );
- short RoundUp( const double );
- void ResetForeAndBackColors( void );
- void UpdateGWorldColors( void );
-
- // • E V E N T S . C
-
- void MainEventLoop( void );
- void ResetWindBkgnd( void );
-
- // • D I A L O G S . C
-
- void FrameSzDlg( void );
- void FilmDlg( void );
- void GrayDlg( void );
- void MonitorDlg( void );
-
- // • F I L E S . C
-
- void DisposeFramePICTs( void );
- void OpenFilm( void );
- void SaveFilm( void );
-
- // • M A I N . C
-
- void CleanUp( void );
- void ErrNumToPstr( const short, char * );
- void ErrorHandler( const short, const char *, const char *, const char * );
- void MaximizeHeap( const long );
-
- // • S E T U P . C
-
- void CleanUpOffScreen( void );
- void GetNumMonitors();
- void InitManagers( void );
- void InitOffScreen( void );
- void InitPalette( void );
- void SetUpMenus( void );
- void SetUpWindows( void );
- void UpdateWindowColors( void );
-
- // • V B L A N K . C
-
- void SetUpVBlankAnimation( void );
- void ShutDownVBlankAnimation( void );
- void VideoProc( void );
-
- // • ----------------------------------------------------------------------
-
- #endif
-